package com.mz.ozy.activity.c2c;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.mz.ozy.R;
import com.mz.ozy.base.BaseActivity;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class C2cTradeActivity extends BaseActivity {

    @BindView(R.id.tabLayout)
    SlidingTabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;

    private Fragment[] fragments;
    private String[] titles;
    private FragmentPagerAdapter adapter;
    private int selectIndex = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_c2_ctrade);
        ButterKnife.bind(this);
        initTitle();
        tvCenterTitle.setText(R.string.str_c2c_title);
        initTab();
    }

    private void initTab() {
        titles = getResources().getStringArray(R.array.c2c_tab);
        fragments = new Fragment[]{C2cTradeFragment.newInstance("1"), C2cTradeFragment.newInstance("2")};
        adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int i) {
                return fragments[i];
            }

            @Override
            public int getCount() {
                return titles.length;
            }
        };
        viewPager.setOffscreenPageLimit(titles.length);
        viewPager.setAdapter(adapter);
        tabLayout.setViewPager(viewPager, titles);
        viewPager.setCurrentItem(0);
        tabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                if (position == 0) {
                } else {
                }
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {
            }

            @Override
            public void onPageSelected(int i) {
                if (i == 0) {
                } else {
                }
                selectIndex = i;
            }

            @Override
            public void onPageScrollStateChanged(int i) {
            }
        });
    }


    @OnClick({R.id.rightImage, R.id.rightImage2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rightImage:
                Intent intent0 = new Intent(this, C2cSettingActivity.class);
                startActivity(intent0);
                break;
            case R.id.rightImage2:

                break;
        }
    }
}
